﻿using System;
using System.Collections.Generic;
using Acr.UserDialogs;
using Cashbook.ViewModels;
using Xamarin.Forms;

namespace Cashbook.Views
{
    public partial class StatisticsPage : ContentPage
    {
        public StatisticsVM _statisticsVM;
        public StatisticsPage()
        {
            InitializeComponent();
            _statisticsVM = new StatisticsVM(UserDialogs.Instance);

            this.BindingContext = _statisticsVM;
        }

		protected override void OnAppearing()
        {
			base.OnAppearing();

            if (_statisticsVM.MonthStatics.Count == 0)
                _statisticsVM.LoadDataCommand.Execute(null);
		}

        public void Handle_ItemTapped(object sender, ItemTappedEventArgs e)
        {
			if (e.Item == null) return;
			// do something with e.SelectedItem
			((ListView)sender).SelectedItem = null; // de-select the row
		}
    }
}
